﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BI.CF.IDAL;
using BI.CF.Model;
using System.Data;
using System.Data.SqlClient;

namespace BI.CF.DAL
{
    public  class Admin_Dal:Admin_Idal
    {
        /// <summary>
        /// 后台管理员登录
        /// </summary>
        /// <param name="Admin_Name"></param>
        /// <param name="Admin_Pwd"></param>
        /// <returns></returns>
        public BackAdminModel Admin_DoLogin(string Admin_Name, string Admin_Pwd)
        {
            BackAdminModel Bmodel = null;
            List<BackAdminModel> BList = new List<BackAdminModel>();
            try
            {
                  SqlDataReader Reader=DbHelperSQL.RunProcedurenull("PROC_Admin_Login");
                  while (Reader.Read())
                  {
                      Bmodel = new BackAdminModel();
                      Bmodel.Admin_addres = Reader["Admin_addres"].ToString();
                      Bmodel.Admin_id = Convert.ToInt32(Reader["Admin_id"]);
                      Bmodel.Admin_LogName = Reader["Admin_LogName"].ToString();
                      Bmodel.Admin_LogPwd = Reader["Admin_LogPwd"].ToString();
                      Bmodel.Admin_Name = Reader["Admin_Name"].ToString();
                      Bmodel.Admin_Roleid = Convert.ToInt32(Reader["Admin_Roleid"]);
                      Bmodel.Admin_Tel = Reader["Admin_Tel"].ToString();
                      BList.Add(Bmodel);
                  }
                  Bmodel=BList.Where(p => p.Admin_LogName == Admin_Name && p.Admin_LogPwd == Admin_Pwd).FirstOrDefault();
            }
            catch (Exception ee)
            {
                string Error = ee.Message;
            }
            return Bmodel;
        }
    }
}
   